﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AMS.DD35.Common.Data;
using System.Web.Mvc;
using AMS.DD35.Common;

namespace AMS.DD35.WebMVC3.Models
{
    public class CharacterModel : CharacterData
    {
        public SelectList MoralAlignments { get; set; }

        public SelectList EthicalAlignments { get; set; }

        public CharacterModel()
            : this (null)
        { }

        public CharacterModel(CharacterData data)
        {
            this.MoralAlignments = EnumHelper.ToSelectList<MoralAlignment>();
            this.EthicalAlignments = EnumHelper.ToSelectList<EthicalAlignment>();

            if (data == null)
                return;

            this.BaseCharisma = data.BaseCharisma;
            this.BaseConstitution = data.BaseConstitution;
            this.BaseDexterity = data.BaseDexterity;
            this.BaseIntelligence = data.BaseIntelligence;
            this.BaseStrength = data.BaseStrength;
            this.BaseWisdom = data.BaseWisdom;
            this.CharacterID = data.CharacterID;
            this.CharacterName = data.CharacterName;
            this.Classes = data.Classes;
            this.Copper = data.Copper;
            this.DeityID = data.DeityID;
            this.EthicalAlignment = data.EthicalAlignment;
            this.Experience = data.Experience;
            this.EyeColor = data.EyeColor;
            this.Feats = data.Feats;
            this.Gold = data.Gold;
            this.HairColor = data.HairColor;
            this.Height = data.Height;
            this.HeightUnits = data.HeightUnits;
            this.InherentAbilityGains = data.InherentAbilityGains;
            this.MoralAlignment = data.MoralAlignment;
            this.Platinum = data.Platinum;
            this.RaceID = data.RaceID;
            this.Sex = data.Sex;
            this.Silver = data.Silver;
            this.SkillPoints = data.SkillPoints;
            this.UserName = data.UserName;
            this.Weight = data.Weight;
            this.WeightUnits = data.WeightUnits;
        }

        public override string ToString()
        {
            return base.ToString();
        }

        internal CharacterData ToData()
        {
            CharacterData data = new CharacterData();
            data.BaseCharisma = this.BaseCharisma;
            data.BaseConstitution = this.BaseConstitution;
            data.BaseDexterity = this.BaseDexterity;
            data.BaseIntelligence = this.BaseIntelligence;
            data.BaseStrength = this.BaseStrength;
            data.BaseWisdom = this.BaseWisdom;
            data.CharacterID = this.CharacterID;
            data.CharacterName = this.CharacterName;
            data.Classes = this.Classes;
            data.Copper = this.Copper;
            data.DeityID = this.DeityID;
            data.EthicalAlignment = this.EthicalAlignment;
            data.Experience = this.Experience;
            data.EyeColor = this.EyeColor;
            data.Feats = this.Feats;
            data.Gold = this.Gold;
            data.HairColor = this.HairColor;
            data.Height = this.Height;
            data.HeightUnits = this.HeightUnits;
            data.InherentAbilityGains = this.InherentAbilityGains;
            data.MoralAlignment = this.MoralAlignment;
            data.Platinum = this.Platinum;
            data.RaceID = this.RaceID;
            data.Sex = this.Sex;
            data.Silver = this.Silver;
            data.SkillPoints = this.SkillPoints;
            data.UserName = this.UserName;
            data.Weight = this.Weight;
            data.WeightUnits = this.WeightUnits;
            return data;
        }
    }
}